package edu.gatech.oad.OTConfig;
import java.util.LinkedList;

/**
 * This is the TrailNavigator Class
 * This class contains a linked list that tracks locations along the trail and has methods to update the location.
 * @author Chris Adams
 * @version 1.0 11/4/2011
 */

public class TrailNavigator extends LinkedList<TrailNode> {
	private TrailNode currentLocation;
	private int milesToNext;
	
	//Constructor - adds nodes representing locations to linked list
	public TrailNavigator(){
		//String location, int milesToNext, boolean isEndOfJourney, boolean isRiver, boolean hasStore, boolean isDestination
		add(new TrailNode("Independence", 0, false, false, true, true));
		add(new TrailNode("On the way to Kansas River", 102, false, false, false, false));
		add(new TrailNode("Kansas River", 0, false, true, false, true));
		add(new TrailNode("On the way to Big Blue", 82, false, false, false, false));
		add(new TrailNode("Big Blue", 0, false, true, false, true));
		add(new TrailNode("On the way to Fort Kearny", 119, false, false, false, false));
		add(new TrailNode("Fort Kearny", 0, false, false, true, true));
		add(new TrailNode("On the way to Chimney Rock", 250, false, false, false, false));
		add(new TrailNode("Chimney Rock", 0, false, false, false, true));
		add(new TrailNode("On the way to Fort Laramie", 86, false, false, false, false));
		add(new TrailNode("Fort Laramie", 0, false, false,true, true));
		add(new TrailNode("On the way to Independence Rock", 190, false, false, false, false));
		add(new TrailNode("Independence Rock", 0, false, false, false, true));
		add(new TrailNode("On the way to South Pass", 102, false, false, false, false));
		add(new TrailNode("South Pass", 0, false, false, false, true));
		add(new TrailNode("On the way to Soda Springs", 162, false, false, false, false));
		add(new TrailNode("Soda Springs", 0, false, false, false, true));
		add(new TrailNode("On the way to Fort Hall", 57, false, false, false, false));
		add(new TrailNode("Fort Hall", 0, false, false, true, true));
		add(new TrailNode("On the way to Snake River Crossing", 182, false, false, false, false));
		add(new TrailNode("Snake River Crossing", 0, false, true, false, true));
		add(new TrailNode("On the way to Fort Boise", 114, false, false, false, false));
		add(new TrailNode("Fort Boise", 0, false, false, true, true));
		add(new TrailNode("On the way to Blue Mountains", 162, false, false, false, false));
		add(new TrailNode("Blue Mountains", 0, false, false, false, true));
		add(new TrailNode("On the way to Fort Walla Walla", 55, false, false, false, false));
		add(new TrailNode("Fort Walla Walla", 0, false, false, true, true));
		add(new TrailNode("On the way to Fort Vancouver", 120, false, false, false, false));
		add(new TrailNode("Fort Vancouver", 0, false, false, false, true));
		add(new TrailNode("On the way to Oregon City", 92, false, false, false, false));
		add(new TrailNode("Oregon City", 0, true, false, false, true));
		this.currentLocation = this.getFirst();
	}
	
	//Returns index of current location
	public int getCurrentIndex(){
		return this.indexOf(currentLocation);
	}
	
	public void goToLocation(int index){
		currentLocation = this.get(index);
	}
	//Sets current location to next location
	public void goToNextLocation(){
		currentLocation = this.get(this.indexOf(currentLocation) + 1);
	}
	
	//Returns boolean indicating if journey is over
	public boolean getIsEndOfJourney(){
		return currentLocation.getIsEndOfJourney();
	}
	
	//Returns boolean indicating if store is present at location
	public boolean getHasStore(){
		return currentLocation.getHasStore();
	}
	
	//Returns boolean indicating if river is present at location
	public boolean getIsRiver(){
		return currentLocation.getIsRiver();
	}
	
	//Returns boolean indicating if current location is destination
	public boolean getIsDestination(){
		return currentLocation.getIsDestination();
	}
	
	//Returns miles to next location
	public int getMilesToNext(){
		return currentLocation.getMilesToNext();
	}
	
	public void setMilesToNext(int miles){
		currentLocation.setMilesToNext(miles);
	}
	
	//Updates miles to next location
	public void updateMilesToNext(int milesTraveled){
		currentLocation.updateMilesToNext(milesTraveled);
	}
	
	//Returns current location
	public String getLocation(){
		return currentLocation.getLocation();
	}
	
	//Returns current location
	public TrailNode getCurrentLocation(){
		return currentLocation;
	}
	
	
}